package com.cheng.web.action.system;

import java.util.List;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.cheng.bos.actionUtils.ActionUtils;
import com.cheng.domain.system.Permission;
import com.cheng.service.system.PermissionService;
import com.opensymphony.xwork2.ActionContext;
import com.sun.net.httpserver.Authenticator.Success;

@ParentPackage("json-default")
@Controller
@Scope("prototype")
@Namespace("/permission")
public class PermissionAction extends ActionUtils<Permission> {
	@Autowired
	private PermissionService permissionService;
	
	@Action(value="permission_query",results={@Result(name="success",type="json")})
	public String queryPermission(){
		List<Permission> list =permissionService.findAll();
		ActionContext.getContext().getValueStack().push(list);
		return SUCCESS;
	}
	
	@Action(value="permission_save",results={@Result(name="success",type="redirect",location="../pages/system/permission.html")})
	public String savePermission(){
		permissionService.save(model);
		return SUCCESS;
	}

}
